import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Locale;


@SuppressWarnings("ObjectEqualsNull")
public class Conection implements DB_Conection{
    Conection(){

    }

    @Override
    public Connection Conect(String name, String password, String Driver_Name,
                             String URL, String SID, String server, String port)  {
        server = "localhost";
        Driver_Name = "oracle.jdbc.driver.OracleDriver";
        SID = "XE";
        port = "1521";
        name = "test";
        password = "123456";

        Connection con = null;
        try{
            URL = "jdbc:oracle:thin:@" + server           //генерируем верный URL
                    + ":" + port + ":" + SID;
            Class.forName(Driver_Name);
            Locale.setDefault(Locale.ENGLISH);  //необходимо для конекта т.к. версия xe
            con = DriverManager.getConnection(URL,name, password );    //пробуем подключиться к БД



        } catch (ClassNotFoundException cex) {
            cex.printStackTrace();

        }
            catch (SQLException sex) {
                sex.printStackTrace();

            }
               catch (Exception ex) {
                   ex.printStackTrace();

               }           //отлов исключений и ошибок


        assert con != null;
        //noinspection ObjectEqualsNull
        if (con.equals(null)){
              System.out.println("not connected!!!!!");

          }



        return con;  //To change body of implemented methods use File | Settings | File Templates.
    }
}
